/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.primitivies;

/**
 *
 * @author admin
 */
public class Curve {

    private Ellipse ellipse;
    private Point2d point;

    public Curve(Ellipse ellipse, Point2d point) {
        this.ellipse = ellipse;
        this.point = point;
    }

    public double getC() {
        return ellipse.getC();
    }

    public double genXpos(double x1) {
        double result = x1 + ((ellipse.getB() * (point.getX() - x1)) / ellipse.getC())
                * Math.sqrt((ellipse.getC() * ellipse.getC() - x1 * x1) / ((point.getX() - x1) * (point.getX() - x1)
                        + point.getY() * point.getY()));
        return result;
    }

    public double genXneg(double x1) {
        double result = x1 - ((ellipse.getB() * (point.getX() - x1)) / ellipse.getC())
                * Math.sqrt((ellipse.getC() * ellipse.getC() - x1 * x1) / ((point.getX() - x1) * (point.getX() - x1)
                        + point.getY() * point.getY()));
        return result;
    }

    public double genYpos(double x1) {
        double result = ((point.getY() * ellipse.getB()) / ellipse.getC())
                * Math.sqrt((ellipse.getC() * ellipse.getC() - x1 * x1)
                        / ((point.getX() - x1) * (point.getX() - x1) + point.getY() * point.getY()));
        return result;
    }

    public double genYneg(double x1) {
        double result = ((point.getY() * ellipse.getB()) / ellipse.getC())
                * Math.sqrt((ellipse.getC() * ellipse.getC() - x1 * x1)
                        / ((point.getX() - x1) * (point.getX() - x1) + point.getY() * point.getY()));
        return result;
    }
}
